//
//  HLTShopViewController.m
//  huiliantong
//
//  Created by hlt on 15/8/17.
//  Copyright (c) 2015年 hlt. All rights reserved.
//

#import "HLTShopViewController.h"
#import "HLTScrollView.h"
#import "HLTGoumaiview.h"
#import "HLTBeenAndCollectView.h"
#import "HLTShopinfoTableViewCell.h"
#import "HLTShopaddressTableViewCell.h"
#import "HLTtelandadressTableViewCell.h"
#import "ContentTableViewCell.h"
#import "RecommendCell.h"
#import "HLTquzhifuTableViewController.h"
#import "HLTqupinglunTableViewController.h"
#import "HLTpinglunTableViewController.h"
//商铺地图的界面
#import "HLTshopmapViewController.h"

#import "HLTuserchargeViewController.h"


//使用分享的接口
#import "XMShareView.h"
//友盟分享的使用
#import "UMSocial.h"
//顶部scrollHeadView 的高度,先给写死
//static const CGFloat ScrollHeadViewHeight =200;
//选择View的高度
static const CGFloat SelectViewHeight = 50;



@interface HLTShopViewController ()<UITableViewDataSource, UITableViewDelegate, UIScrollViewDelegate, UIActionSheetDelegate,sliderScrollerDelegate,UMSocialUIDelegate>
{
//    CGFloat ScrollHeadViewHeight =screen_width/2;
    NSMutableArray *_recommendArray;
    
    BOOL isshouchang;    //判断是否被收藏
//    CGFloat height=screen_width/2;
}

    /** 地图view */
//    @property (nonatomic, strong)  MAMapView *mapView;

     /**顶部的高度    **/
@property (nonatomic,assign) CGFloat ScrollHeadViewHeight;

    /** 记录scrollView上次偏移的Y距离 */
    @property (nonatomic, assign) CGFloat                    scrollY;
    /** 记录scrollView上次偏移X的距离 */
    @property (nonatomic, assign) CGFloat                    scrollX;
    /** 最底部的scrollView，用来掌控所有控件的滚动 */
    @property (nonatomic, strong) UIScrollView               *backgroundScrollView;
   
    /** 用来装顶部的scrollView用的View */
    @property (nonatomic, strong) UIView                     *topView;
    /** 顶部的图片scrollView */
    @property (nonatomic, strong) HLTScrollView          *topScrollView;
    /** 返回按钮 */
    @property (nonatomic, strong) UIButton                   *backBtn;
    /** 分享按钮 */
    @property (nonatomic, strong) UIButton                   *sharedBtn;
    /** 导航条的title */
    @property (nonatomic, strong) UILabel                    *titleLabel;
    /** 导航条下边的副标题 */
    @property (nonatomic, strong) UILabel                    *subTitleLabel;
    /** 副标题旁边的小图片 */
    @property (nonatomic, strong) UIImageView                *smallImageView;
    /** 选择tableView的view */
    @property (nonatomic, strong) HLTGoumaiview              *selectView;
    /** 导航条的背景view */
    @property (nonatomic, strong) UIView                     *naviView;
    /** 推荐tableViewtableHeadView */
//    @property (nonatomic, strong) WNXDetailRnmdTableHeadView *tableHeadView;
    /** 所有rmdTableView的foodView */
//    @property (nonatomic, strong) WNXDetailFootView          *footView;
//    /** infoTableView的footView */
//    @property (nonatomic, strong) WNXDetailFootView          *footView1;
    /** 信息tableView */
    @property (nonatomic, strong) UITableView                *infoTableView;
    /** 记录当前展示的tableView 计算顶部topView滑动的距离 */
    @property (nonatomic, weak  ) UITableView                *showingTableView;
    /** 去过和收藏view */
    @property (nonatomic, strong) HLTBeenAndCollectView      *beenAndCollectView;
    /** 推荐tableView的数据源 */
    @property (nonatomic, strong) NSMutableArray             *rmdDatas;
    /** 详情页的总数据 */
//    @property (nonatomic, strong) WNXDetailModel             *details;
    /** 信息tableview的数据 */
    @property (nonatomic, strong) NSMutableArray *infoDatas;
    
    /** 电话提示 */
    @property (nonatomic, strong) UIActionSheet *actionSheet;

    //分享需要使用的
@property (nonatomic, strong) XMShareView *shareView;

//收藏按钮
@property (nonatomic, strong) UIButton *collectBtn;




@end

@implementation HLTShopViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.yinchang=YES;
    //是否收藏默认为yes
    isshouchang=YES;
    //标志是不是从周边商户点击来的
//    self.biaozhi=YES;
    
    
    _ScrollHeadViewHeight=screen_width/1.5;
    
    
    NSString *shopid;
    if (_biaozhi) {
        shopid=self.shopcontent.Shop_id;
    }else
    {
        shopid=self.zhoubianshopcontent.id;
    }
    
    self.shopID=shopid;
    
    
    //初始化界面
    [self setUI];
    
    //初始化导航条上的内容
    [self setUpNavigtionBar];
    [self getrecommendlist];
    
}



//获取推荐商铺列表
-(void) getrecommendlist
{
      _recommendArray = [[NSMutableArray alloc] init];   //初始化周边商铺数据
    
    NSString *url;
    if (_biaozhi) {
        //是一般的商铺列表点击进来的
        
        url=[NSString stringWithFormat:@"http://www.hltgz.com/wx/mobile/index.php?m=default&c=appinterface&a=zhoubian&x=%@&y=%@&page=0",self.shopcontent.shop_longitude,self.shopcontent.shop_latitude];
    }
    else
    {
        //是通过周边列表点击进来的
        url=[NSString stringWithFormat:@"http://www.hltgz.com/wx/mobile/index.php?m=default&c=appinterface&a=zhoubian&x=%@&y=%@&page=0",self.zhoubianshopcontent.shop_longitude,self.zhoubianshopcontent.shop_latitude];
    }
    
    
   
    
//    NSString *url=@"http://www.hltgz.com/wx/mobile/index.php?m=default&c=appinterface&a=zhoubian&x=横坐标&y=纵坐标&page=";
    [HLTNetWorkingtool getzhoubianlist:url success:^(NSMutableArray *ary) {
        
        [_recommendArray removeAllObjects];
        for (int i = 0; i < ary.count; i++) {
            HLTZhoubianModel *recommend = [HLTZhoubianModel objectWithKeyValues:ary[i]];
            [_recommendArray addObject:recommend];
        }
        
        //刷新指定的section,显示推荐商铺的部分
        NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:3];
        [self.rmdTableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic];
        
    } faliure:^(NSString *error) {
        
        
        
    }];
    
    
    
    
    
}



- (void)setUI
{
    //隐藏系统的导航条，由于需要自定义的动画，自定义一个view来代替导航条
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    
    //将view的自动添加scroll的内容偏移关闭
    self.automaticallyAdjustsScrollViewInsets = NO;
    //设置背景色
    self.view.backgroundColor = [UIColor whiteColor];
    //初始化最底部的scrollView,装tableView用
    self.backgroundScrollView = [[UIScrollView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    [self.view addSubview:self.backgroundScrollView];
    self.backgroundScrollView.backgroundColor = [UIColor whiteColor];
    self.backgroundScrollView.pagingEnabled = YES;
    self.backgroundScrollView.bounces = NO;
    self.backgroundScrollView.showsHorizontalScrollIndicator = NO;
    self.backgroundScrollView.delegate = self;
    self.backgroundScrollView.contentSize = CGSizeMake(screen_width, 0);
    
    //初始化推荐tabelView,最多有3个tableView，暂时只做俩个tableView，所以两个tableview就都在一个控制器里写了
    //如果tableview很多推荐用一个tableview用一个空气器来管理，注意控制器之间的父子关系
//    self.rmdTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, screen_width, screen_height-64) style:UITableViewStylePlain];
    self.rmdTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, screen_width, screen_height) style:UITableViewStylePlain];
    self.rmdTableView.delegate = self;
    self.rmdTableView.dataSource = self;
    
  
    self.rmdTableView.backgroundColor = [UIColor whiteColor];
    //给顶部的图片view和选择view留出距离
    [self.backgroundScrollView addSubview:self.rmdTableView];
    self.rmdTableView.contentInset = UIEdgeInsetsMake(_ScrollHeadViewHeight + SelectViewHeight, 0, 0, 0);
    //取消推荐tableview的分割线
//    self.rmdTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    NSArray *array;
    if (_biaozhi) {
         array= [self.shopcontent.images componentsSeparatedByString:@","];
    }
    else
    {
        array= [self.zhoubianshopcontent.images componentsSeparatedByString:@","];
    }
    
    
    
    NSMutableArray *mary=[[NSMutableArray alloc] initWithCapacity:3];
    for (NSString *value in array) {
        
        NSString *str=[imageurl stringByAppendingString:value];
        [mary addObject:str];
    }
    
    
    
    
    //添加顶部的图片scrollView
    //    NSArray *arr = @[@"http://img.chengmi.com/cm/3bc2198c-c909-4698-91b2-88e00c5dff2a",
    //                     @"http://img.chengmi.com/cm/dba3fb4d-b5ef-4218-b976-52cba4538381",
    //                     @"http://img.chengmi.com/cm/934ad87f-400c-452e-9427-12a03fe9cf6e"];
    
    
    if (mary.count<1) {
        NSString *str=[imageurl stringByAppendingString:@"images/201509/shopthumb_img/11_thumb_G_1442534292764.jpg"];
        [mary addObject:str];
    }
    
    
    
    self.topScrollView = [HLTScrollView HLTScrollViewWithImagesWithImages:mary];
    [self.topScrollView setFrame:CGRectMake(0, 0, screen_width, _ScrollHeadViewHeight)];
    
    //添加顶部view用做topScrollView的父控件，因为在topScrollView内部youpageView应该在同一父控件中，方便后面做拉伸动画
    self.topView = [[UIView alloc] initWithFrame:self.topScrollView.bounds];
    self.topView.backgroundColor = [UIColor clearColor];
    [self.topView addSubview:self.topScrollView];
    [self.view addSubview:self.topView];
    
    //添加WNXSelectView在View,根据scrollViewY轴的偏移量算出selectView的位置
//    _selectView = [HLTGoumaiview getHLTGoumaiview];
    
    _selectView= [[[NSBundle mainBundle]loadNibNamed:@"HLTGoumaiview" owner:nil options:nil] firstObject];
    
    
    [_selectView.goumai addTarget:self action:@selector(goumai) forControlEvents:UIControlEventTouchDown];
    
    
    
    
    Account *acc=[[AccountTool sharedAccountTool] currentAccount];
    if ([acc.custIdent isEqual:@""]) {
        _selectView.goumai.hidden=YES;
    }
    else{
        
        if ([self.shopcontent.business_id isEqual:@"0"]||[self.zhoubianshopcontent.business_id isEqual:@"0"]) {
            
            _selectView.goumai.hidden=YES;
            
            
        }else{
            
            _selectView.goumai.hidden=NO;
            
        }
        
    }
    
    
    
    
    
    
    
    NSInteger starnum;
    
    if (_biaozhi) {
        starnum=([self.shopcontent.sort_order integerValue]-50)/10+1;
    }
    else
    {
         starnum=([self.zhoubianshopcontent.sort_order integerValue]-50)/10+1;
        
    }

    
    if (_biaozhi) {
    if ([self.shopcontent.sort_order integerValue]<50) {
        starnum=0;
    }
    }else
    {
        if ([self.zhoubianshopcontent.sort_order integerValue]<50) {
            starnum=0;
        }
        
    }
    
    
    _selectView.tuijiandengji.show_star=starnum;
    
    
    
//    _selectView.tuijiandengji.frame=CGRectMake(10, 15, 120, 30);
    
//    LDXScore *starview=[[LDXScore alloc]initWithFrame:CGRectMake(10, 15, 120, 30)];
//    starview.normalImg=[UIImage imageNamed:@"btn_star_evaluation_normal"];
//    starview.highlightImg=[UIImage imageNamed:@"btn_star_evaluation_press"];
//    starview.isSelect=NO;
//    starview.max_star=5;
//    starview.padding=0;
//    starview.show_star=starnum;
//    
//    
//    [_selectView addSubview:starview];
    
    
//    /* 距离左边的间距 */
//    @property (nonatomic, assign) IBInspectable CGFloat padding;
//    /* 最多的星数，默认为5 */
//    @property (nonatomic, assign) IBInspectable NSInteger max_star;
//    /* 是否支持选择星数 */
//    @property (nonatomic, assign) IBInspectable BOOL isSelect;
//    @property (nonatomic, strong) IBInspectable UIImage *normalImg;
//    @property (nonatomic, strong) IBInspectable UIImage *highlightImg;
    
    
//    _selectView.delegate = self;
    _selectView.frame = CGRectMake(0, CGRectGetMaxY(self.topView.frame), screen_width, SelectViewHeight);
    [self.view addSubview:_selectView];
    
    //添加推荐tableView的tableHeadView
//    self.tableHeadView = [WNXDetailRnmdTableHeadView detailRnmdTableHeadView];
//    self.rmdTableView.tableHeaderView = self.tableHeadView;
//    self.tableHeadView.superNC = self.navigationController;
    
    //最上层添加收藏去去过的view,这个view很多页面都有，并且需要调用数据库判断以前时候操作过，建议封装一个专门的管理工具用来管理这个控件
    self.beenAndCollectView = [HLTBeenAndCollectView beenAndCollectView];
    CGFloat beenAndCollectViewH = 64;
    self.beenAndCollectView.frame = CGRectMake(0, screen_height - beenAndCollectViewH, screen_width, beenAndCollectViewH);
//    [self.view addSubview:self.beenAndCollectView];
    
    //初始化地图
    //    [MAMapServices sharedServices].apiKey = @"2e6b9f0a88b4a79366a13ce1ee9688b8";
    //    self.mapView = [[MAMapView alloc] initWithFrame:CGRectMake(0, 0, WNXAppWidth, 220)];
    //    self.mapView.delegate = self;
    //    self.mapView.showsScale = NO;
    //    self.mapView.showsCompass = NO;
    //    self.mapView.showsUserLocation = YES;
    //    self.mapView.logoCenter = CGPointMake(WNXAppWidth - self.mapView.logoSize.width + 5, 220 - self.mapView.logoSize.height);
    //    _mapView.zoomEnabled = NO;
    //    self.mapView.scrollEnabled = NO;
    //    [self.mapView setCenterCoordinate:CLLocationCoordinate2DMake(39.906598, 116.400673) animated:YES];
    //    self.mapView.delegate = self;
    //    self.mapView.zoomLevel = 14;
    //
    //    //添加自定义图片
    //    MAPointAnnotation *pointAnnotation = [[MAPointAnnotation alloc] init];
    //    pointAnnotation.coordinate = CLLocationCoordinate2DMake(39.906598, 116.400673);
    //    [_mapView addAnnotation:pointAnnotation];
    //    self.infoTableView.tableHeaderView = self.mapView;
}



//初始化导航条上的内容
- (void)setUpNavigtionBar
{
    //初始化山寨导航条
    self.naviView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screen_width, 64)];
    self.naviView.backgroundColor = navigationBarColor;
    self.naviView.alpha = 0.0;
    [self.view addSubview:self.naviView];
    
    //添加返回按钮
    self.backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.backBtn.frame = CGRectMake(5, 30, 25, 25);
    [self.backBtn addTarget:self action:@selector(backButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.backBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    [self.view addSubview:self.backBtn];
    
    
    
    
    
    
    //收藏
//    _collectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    _collectBtn.frame = CGRectMake(screen_width-10-23-10-23, 34, 22, 22);
////    [_collectBtn setImage:[UIImage imageNamed:@"icon_collect"] forState:UIControlStateNormal];
////    [_collectBtn setImage:[UIImage imageNamed:@"icon_collect_highlighted"] forState:UIControlStateHighlighted];
//    [_collectBtn addTarget:self action:@selector(shoucang:) forControlEvents:UIControlEventTouchDown];
//    [self jianchashouchang];
//    [self.view addSubview:_collectBtn];
    
    
    
    
    //分享
//    UIButton *shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    shareBtn.frame = CGRectMake(screen_width-10-23, 34, 22, 22);
//    [shareBtn setImage:[UIImage imageNamed:@"btn_share_normal"] forState:UIControlStateNormal];
////    [shareBtn setImage:[UIImage imageNamed:@"icon_merchant_share_highlighted"] forState:UIControlStateHighlighted];
//    [shareBtn addTarget:self action:@selector(sharedBtnClick:) forControlEvents:UIControlEventTouchDown];
//    
//    [self.view addSubview:shareBtn];
//    
//    self.sharedBtn=shareBtn;
    
    
//    [backView addSubview:shareBtn];
    
//    //分享按钮
    self.sharedBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.sharedBtn.frame = CGRectMake(screen_width - 36, 34, 26, 17);
    [self.sharedBtn setImage:[UIImage imageNamed:@"btn_share_normal"] forState:UIControlStateNormal];
    [self.sharedBtn addTarget:self action:@selector(sharedBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.sharedBtn];
    
    //添加导航条上的大文字
    self.titleLabel = [[UILabel alloc] init];
    [self.titleLabel setFrame:CGRectMake(30, 32, screen_width - 35 - 50, 25)];
    self.titleLabel.textAlignment = NSTextAlignmentLeft;
    self.titleLabel.font = [UIFont systemFontOfSize:19];
    if (_biaozhi) {
        self.titleLabel.text = self.shopcontent.Shop_name;
    }else
    {
        self.titleLabel.text = self.zhoubianshopcontent.name;
    }
    
    
    self.titleLabel.textColor = [UIColor whiteColor];
    [self.view addSubview:self.titleLabel];
    
    //添加导航条下面的小图片
    self.smallImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"index_navigation_nearby"]];
    self.smallImageView.frame = CGRectMake(30, 60, 14, 18);
    [self.view addSubview:self.smallImageView];
    
    //添加副标题
    self.subTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(52, 60, screen_width - 180, 20)];
    self.subTitleLabel.textAlignment = NSTextAlignmentLeft;
    self.subTitleLabel.textColor = [UIColor whiteColor];
    self.subTitleLabel.font = [UIFont systemFontOfSize:16];
    if (_biaozhi) {
        self.subTitleLabel.text = self.shopcontent.shop_intro;
    }else
    {
        self.subTitleLabel.text = self.zhoubianshopcontent.shop_intro;
    }
    
    
    
    if ([self.subTitleLabel.text isEqual:@"00"]) {
        
        self.subTitleLabel.text=@"";
    }
    
    
//    self.subTitleLabel.text = self.shopcontent.shop_intro;
    [self.view addSubview:self.subTitleLabel];
    
}

//返回上个控制器
- (void)backButtonClick:(UIButton *)sender
{
    
    self.yinchang=NO;
    
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)sharedBtnClick:(UIButton *)sender
{
    
    
    //一下是使用xmshare的接口
    //    if(!self.shareView){
    //
    //        self.shareView = [[XMShareView alloc] initWithFrame:self.view.bounds];
    //
    //        self.shareView.alpha = 0.0;
    //
    //        self.shareView.shareTitle = NSLocalizedString(@"分享标题", nil);
    //
    //        self.shareView.shareText = NSLocalizedString(@"分享内容", nil);
    //
    //        self.shareView.shareUrl = @"http://amonxu.com";
    //
    //        [self.view addSubview:self.shareView];
    //
    //        [UIView animateWithDuration:1 animations:^{
    //            self.shareView.alpha = 1.0;
    //        }];
    //
    //
    //    }else{
    //        [UIView animateWithDuration:1 animations:^{
    //            self.shareView.alpha = 1.0;
    //        }];
    //        
    //    }
    
    
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:@"561b771c67e58eb172000bd4"
                                      shareText:@"汇联通支付"
                                     shareImage:[UIImage imageNamed:@"LOGO.png"]
                                shareToSnsNames:@[UMShareToQQ,UMShareToQzone,UMShareToSina,UMShareToTencent,UMShareToRenren,UMShareToWechatSession,UMShareToWechatTimeline,UMShareToWechatFavorite]
                                       delegate:self];
    
    //设置qq分享的链接
    [UMSocialData defaultData].extConfig.qqData.url = @"https://itunes.apple.com/cn/app/id1057062644";
    //设置空间分享的链接
    [UMSocialData defaultData].extConfig.qzoneData.url = @"https://itunes.apple.com/cn/app/id1057062644";
    //设置qq分享的title
    [UMSocialData defaultData].extConfig.qqData.title = @"汇联通";
    //设置qq空间分享的title
    [UMSocialData defaultData].extConfig.qzoneData.title = @"汇联通";
    

    
    
    
    
}


-(void) shoucang:(UIButton *)sender
{
    
    
//    [[UMSocialControllerService defaultControllerService] setShareText:@"分享内嵌文字" shareImage:[UIImage imageNamed:@"icon"] socialUIDelegate:nil];        //设置分享内容和回调对象
//    [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToSina].snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);
    
    
    
    
//    [[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToWechatSession] content:@"分享内嵌文字" image:[UIImage imageNamed:@"icon.png"] location:nil urlResource:nil presentedController:self completion:^(UMSocialResponseEntity *response){
//        if (response.responseCode == UMSResponseCodeSuccess) {
//            NSLog(@"分享成功！");
//        }
//    }];
    
    
    
    
    //支付码支付接口 (user_name=支付方用户名 payToUser=收款方id，shop_id=商铺id amount=支付金额 )
    
//    Account *acc=[[AccountTool sharedAccountTool] currentAccount];
    
//    NSString *str;
//    if (self.xuanzhe==0) {
//        
//        str=pakeyzhifu;
//    }
//    else
//    {
//        str=yuepay;
//    }
    
    NSString *shopid;
    if (_biaozhi) {
        shopid=self.shopcontent.Shop_id;
    }else
    {
        shopid=self.zhoubianshopcontent.id;
    }
    
    
     Account *acc=[[AccountTool sharedAccountTool] currentAccount];
    if (isshouchang) {
        //已经收藏
        //取消收藏 (&username=18285117086&shop_id=476)
        NSString *url=[quxiaoshouchang stringByAppendingFormat:@"&username=%@&shop_id=%@",acc.custPhone,shopid];
        [HLTNetWorkingtool getdic:url success:^(NSDictionary *ary) {
            
            
        } faliure:^(NSString *error) {
            
        }];
    }
    else
    {
    //添加收藏 (&username=18285117086&shop_id=476)
    NSString *url=[insertshouchang stringByAppendingFormat:@"&username=%@&shop_id=%@",acc.custPhone,shopid];
    [HLTNetWorkingtool getdic:url success:^(NSDictionary *ary) {
        
        
    } faliure:^(NSString *error) {
        
        
        
    }];
    }
    
    
    [self jianchashouchang];

    
}



-(void) jianchashouchang
{
    Account *acc=[[AccountTool sharedAccountTool] currentAccount];
    NSString *shopid;
    if (_biaozhi) {
        shopid=self.shopcontent.Shop_id;
    }else
    {
        shopid=self.zhoubianshopcontent.id;
    }
    
    
    if ([acc.custPhone isEqual:@""]) {
        
        UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示" message:@"您还未登录，要想有更好的体验请登录！" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"好", nil];
        
        [alert show];
    }
    else
    {
    
    
    //添加收藏 (&username=18285117086&shop_id=476)
    NSString *url=[shifoushouchang stringByAppendingFormat:@"&username=%@&shop_id=%@",acc.custPhone,shopid];
    [HLTNetWorkingtool getdic:url success:^(NSDictionary *ary) {
        
        if ([ary[@"msg"] integerValue]>=1) {
            //已经收藏
            

            [_collectBtn setImage:[UIImage imageNamed:@"icon_collect_highlighted"] forState:UIControlStateNormal];
            isshouchang=YES;
        }
        else
        {
            isshouchang=NO;
            [_collectBtn setImage:[UIImage imageNamed:@"icon_collect"] forState:UIControlStateNormal];
        }
    } faliure:^(NSString *error) {
    }];
    
    }
}




#pragma mark - 友盟分享结束的回调方法
-(void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)response
{
    //根据`responseCode`得到发送结果,如果分享成功
    if(response.responseCode == UMSResponseCodeSuccess)
    {
        //得到分享到的微博平台名
        NSLog(@"share to sns name is %@",[[response.data allKeys] objectAtIndex:0]);
    }
}




-(void) goumai
{
    Account *acc=[[AccountTool sharedAccountTool] currentAccount];
    if ([acc.pwd isEqual:@""]) {
        
        UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示" message:@"亲!您还未登录哟-_- " delegate:nil cancelButtonTitle:nil otherButtonTitles:@"好", nil];
        
        [alert show];
    }
    else{
    
    if ([self.shopcontent.business_id isEqual:@"0"]||[self.zhoubianshopcontent.business_id isEqual:@"0"]) {
        
        UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示" message:@"该商铺还没有绑定商家，不能去消费" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"好", nil];
        [alert show];
        
        
    }else{
        
        UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        HLTquzhifuTableViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"HLTquzhifuTableViewController"];
        
        
        
        
        if (_biaozhi) {
            vc.shop_id=self.shopcontent.Shop_id;
            vc.shop_name=self.shopcontent.Shop_name;
            vc.touser_id=self.shopcontent.business_id;
        }else
        {
            
            vc.shop_id=self.zhoubianshopcontent.id;
            vc.shop_name=self.zhoubianshopcontent.name;
            vc.touser_id=self.zhoubianshopcontent.business_id;
        }
        
        
        
        //设置隐藏属性为no，打开导航
        self.yinchang=NO;
        //    vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:NO];

    }
    
    }
    
    
}

#pragma mark - scrollview的delegate
//这里计算相当繁琐 耐心慢慢来吧
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if (scrollView == self.rmdTableView || scrollView == self.infoTableView) {//说明是tableView在滚动
        
        //记录当前展示的是那个tableView
        self.showingTableView = (UITableView *)scrollView;
        
        //记录出上一次滑动的距离，因为是在tableView的contentInset中偏移的_ScrollHeadViewHeight，所以都得加回来
        CGFloat offsetY = scrollView.contentOffset.y;
        CGFloat seleOffsetY = offsetY - self.scrollY;
        self.scrollY = offsetY;
        
        //修改顶部的scrollHeadView位置 并且通知scrollHeadView内的控件也修改位置
        CGRect headRect = self.topView.frame;
        headRect.origin.y -= seleOffsetY;
        self.topView.frame = headRect;
        
        
        //根据偏移量算出alpha的值,渐隐,当偏移量大于-180开始计算消失的值
        CGFloat startF = -180;
        //初始的偏移量Y值为 顶部俩个控件的高度
        CGFloat initY = SelectViewHeight + _ScrollHeadViewHeight;
        //缺少的那一段渐变Y值
        CGFloat lackY = initY + startF;
        //自定义导航条高度
        CGFloat naviH = 64;
        
        //渐隐alpha值
        CGFloat alphaScaleHide = 1 - (offsetY + initY- lackY) / (initY- naviH - SelectViewHeight - lackY);
        //渐现alph值
        CGFloat alphaScaleShow = (offsetY + initY - lackY) /  (initY - naviH - SelectViewHeight - lackY) ;
        
        if (alphaScaleShow >= 0.98) {
            //显示导航条
            [UIView animateWithDuration:0.04 animations:^{
                self.naviView.alpha = 1;
            }];
        } else {
            self.naviView.alpha = 0;
        }
        self.topScrollView.naviView.alpha = alphaScaleShow;
        self.subTitleLabel.alpha = alphaScaleHide;
        self.smallImageView.alpha = alphaScaleHide;
        
        /* 这段代码很有深意啊。。最开始是直接用偏移量算的，但是回来的时候速度比较快时偏移量会偏度很大
         然后就悲剧了。换了好多方法。。最后才开窍T——T,这一段我会在blog里面详细描述我用的各种错误的方法
         用了KVO监听偏移量的值,切换了selectView的父控件，切换tableview的headView。。。
         */
        if (offsetY >= -(naviH + SelectViewHeight)) {
            self.selectView.frame = CGRectMake(0, naviH, screen_width, SelectViewHeight);
        } else {
            self.selectView.frame = CGRectMake(0, CGRectGetMaxY(self.topView.frame), screen_width, SelectViewHeight);
        }
        
        CGFloat scaleTopView = 1 - (offsetY + SelectViewHeight + _ScrollHeadViewHeight) / 100;
        scaleTopView = scaleTopView > 1 ? scaleTopView : 1;
        
        //算出头部的变形 这里的动画不是很准确，好的动画是一点一点试出来了  这里可能还需要配合锚点来进行动画,关于这种动画我会在以后单开一个项目配合blog来讲解的 这里这就不细调了
        CGAffineTransform transform = CGAffineTransformMakeScale(scaleTopView, scaleTopView );
        CGFloat ty = (scaleTopView - 1) * _ScrollHeadViewHeight;
        self.topView.transform = CGAffineTransformTranslate(transform, 0, -ty * 0.2);
        
        //记录selectViewY轴的偏移量,这个是用来计算每次切换tableView，让新出来的tableView总是在头部用的，
        //现在脑子有点迷糊 算不出来了。。凌晨2.57分~
        CGFloat selectViewOffsetY = self.selectView.frame.origin.y - _ScrollHeadViewHeight;
        
        if (selectViewOffsetY != -_ScrollHeadViewHeight && selectViewOffsetY <= 0) {
            
            if (scrollView == self.rmdTableView) {
                
                self.infoTableView.contentOffset = CGPointMake(0, -245 - selectViewOffsetY);
                
            } else {
                
                self.rmdTableView.contentOffset = CGPointMake(0, -245 - selectViewOffsetY);
                
            }
        }
        
    } else {
        //说明是backgroundScrollView在滚动
        
        CGFloat selectViewOffsetY = self.selectView.frame.origin.y - _ScrollHeadViewHeight;
        //让新出来的tableView的contentOffset正好卡在selectView的头上,还是有bug
        if (selectViewOffsetY != -_ScrollHeadViewHeight && selectViewOffsetY <= 0) {
            
            if (self.showingTableView == self.rmdTableView) {
                
                self.infoTableView.contentOffset = CGPointMake(0, -245 - selectViewOffsetY);
                
            } else {
                
                self.rmdTableView.contentOffset = CGPointMake(0, -245 - selectViewOffsetY);
                
            }
        }
        
    }
}





//- (CGFloat)tableView:(UITableView *)tableView  :(NSIndexPath *)indexPath
//{
//    if (tableView == self.rmdTableView) {
//        //推荐tableView
//        return 109;
//    } else {
//        //信息tableVIew
//        return 200;
//    }
//}



#pragma mark - UITableViewDataSource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 4;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSUInteger section = [indexPath section];
    if (0 == section) {
        return 64;
        
    }
    else if(indexPath.section == 1)
    {
        if (indexPath.row == 0) {
            return 35;
        }else{
            
            
            int heig=screen_height;
            if (_height>heig/2.5*1.5-155) {
                return _height;        }
            
            
            
            
            return _height+35;
//            return heig;

        }
    }else if (section==2)
    {
        
        return 50;
    }
    else if (section==3)
    {
        if (indexPath.row==0) {
            return 35;
        }else
        {
            return 90;
        }
        
        
    }
    else
    {
        return 35;
        
    }

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    if (section==0) {
        
        return 3;
    }else if (section==2)
    {
        return 1;
    }
    else if (section==3)
    {
        
        return [_recommendArray count]+1;
        
    }else
    {
        return 2;
    }
    
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 5;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screen_width, 10)];
    headerView.backgroundColor = RGB(239, 239, 244);
    //    headerView.backgroundColor = [UIColor redColor];
    return headerView;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screen_width, 0)];
    footerView.backgroundColor = RGB(239, 239, 244);
    //    footerView.backgroundColor = [UIColor yellowColor];
    return footerView;
}








- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
     NSUInteger section = [indexPath section];
    
    NSInteger row=[indexPath row];
//    static NSString *shopinfocell = @"shopinfocell";
//    static NSString *RecommendTableViewCell1 = @"RecommendTableViewCell1";
//    static NSString *youhuicell = @"youhuicell";
//    
    if (section== 0)
    {
        
        
        if (row==0) {
            static NSString *cellIndentifier = @"addresscell";
            
            
            HLTtelandadressTableViewCell *cell1 = [tableView dequeueReusableCellWithIdentifier:cellIndentifier];
            if(cell1 == nil)
            {
                cell1= [[[NSBundle mainBundle]loadNibNamed:@"HLTtelandadressTableViewCell" owner:nil options:nil] firstObject];
            }
            if (_biaozhi) {
               
                cell1.title.text=self.shopcontent.Shop_address;
                
            }
            else
            {
               cell1.title.text=self.zhoubianshopcontent.shop_address;
                
            }
            
            
            cell1.image.image=[UIImage imageNamed:@"position3.png"];
            cell1.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell1;
        }else if (row==1)
        {
            static NSString *cellIndentifier = @"shoptelcell";
            HLTtelandadressTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIndentifier];
            if(cell == nil)
            {
                cell= [[[NSBundle mainBundle]loadNibNamed:@"HLTtelandadressTableViewCell" owner:nil options:nil] firstObject];
            }
            
            if (_biaozhi) {
                
                cell.title.text=self.shopcontent.Telephone;
                
            }
            else
            {
                cell.title.text=self.zhoubianshopcontent.telephone;
                
            }
            
            cell.image.image=[UIImage imageNamed:@"icon_deal_phone.png"];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell;
            
            
        }else
        {
            static NSString *cellIndentifier = @"fanlicell";
            
            HLTtelandadressTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIndentifier];
            if(cell == nil)
            {
                cell= [[[NSBundle mainBundle]loadNibNamed:@"HLTtelandadressTableViewCell" owner:nil options:nil] firstObject];
            }
            
            if (_biaozhi) {
                int baifenbi=[self.shopcontent.gh_rebate floatValue]*100;
                cell.title.text=[NSString stringWithFormat:@"工会卡返利比例：%d%%",baifenbi];
            }
            else
            {
                
                int baifenbi=[self.zhoubianshopcontent.gh_rebate floatValue]*100;
                cell.title.text= [NSString stringWithFormat:@"工会卡返利比例：%d%%",baifenbi]  ;
                
            }
            
            cell.image.image=[UIImage imageNamed:@"iconfont-chaogaofan.png"];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell;
            
        }
        
    }
    else if (section==1)
    {
        
//       static NSString *cellIndentifier = @"shopcontent";
//        UITableViewCell *cell = [self.rmdTableView dequeueReusableCellWithIdentifier:cellIndentifier];
//        if (cell == nil) {
//            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIndentifier];
//        }
//        cell.backgroundColor=[UIColor grayColor];
//        cell.textLabel.text = @"更多";
//        cell.selectionStyle = UITableViewCellSelectionStyleNone;
//        return cell;
        
        
        
        if(indexPath.row == 0){
            static NSString *cellIndentifier = @"shopcontent";
            
            return  [self gettitlecell:cellIndentifier title:@"详细介绍"];
        }
        else
        {
             static NSString *ContentTableViewCell1 = @"ContentTableViewCell";
            
            ContentTableViewCell *cell2 = [tableView dequeueReusableCellWithIdentifier:ContentTableViewCell1];
            if(cell2 == nil)
            {
                cell2= [[[NSBundle mainBundle]loadNibNamed:@"ContentTableViewCell" owner:nil options:nil] firstObject];
            }
            
            
            for(id subview in cell2.shopcontentweb.subviews)
                if([[subview class] isSubclassOfClass: [UIScrollView class]]) ((UIScrollView *)subview).bounces  =  NO;
            cell2.shopcontentweb.scrollView.bounces = NO;
            
            //设置webview不可点击
            UIScrollView *tempView=(UIScrollView *)[cell2.shopcontentweb.subviews objectAtIndex:0];
            tempView.scrollEnabled=NO;
            
            cell2.selectionStyle=UITableViewCellSelectionStyleNone;
            cell2.parent=self;
            //        cell2.backgroundColor=[UIColor clearColor];//关键语句
            NSString *striing;
            if (_biaozhi) {
                striing=self.shopcontent.Shop_desc;
            }else
            {
                striing=self.zhoubianshopcontent.shop_desc;
            }
            
            NSString *strUrl = [striing stringByReplacingOccurrencesOfString:@"/images" withString:[hltgzimageurl stringByAppendingString:@"images" ]];
            
            NSString *content=  strUrl;
            if ([content length]>0) {
                [cell2.shopcontentweb loadHTMLString:content baseURL:[NSURL fileURLWithPath: [[NSBundle mainBundle]  bundlePath]]];
            }
            return cell2;
        }
    }else if (section==2)
    {
        static NSString *cellIndentifier = @"pinglun";
        
//        return  [self gettitlecell:cellIndentifier title:@"评论"];
//        NSString *cellIndentifier = identifier;
        UITableViewCell *cell = [self.rmdTableView dequeueReusableCellWithIdentifier:cellIndentifier];
        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIndentifier];
        }
//        cell.backgroundColor=navigationBarColor;
        cell.textLabel.text = @"评论";
        cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
//        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        if (_biaozhi) {
            
            cell.detailTextLabel.text=[self.shopcontent.comment stringByAppendingFormat:@"人评价|%@%%好评",self.shopcontent.baifenbi];
        }else
        {
            cell.detailTextLabel.text=[self.zhoubianshopcontent.comment stringByAppendingFormat:@"人评价|%@%%好评",self.zhoubianshopcontent.baifenbi];
        }
        
//        cell.
        
        
        return cell;
        
        
    }
    else if (section==3)
    {
        if(indexPath.row == 0){
            static NSString *cellIndentifier = @"morecell";
            return  [self gettitlecell:cellIndentifier title:@"商铺周边"];

        }else{
            static NSString *cellIndentifier = @"recommendcell";
            RecommendCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIndentifier];
            if (cell == nil) {
                cell = [[RecommendCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIndentifier];
            }
            if(_recommendArray.count!=0){
                HLTZhoubianModel *recommend = _recommendArray[indexPath.row-1];
                [cell setzhoubianlistData:recommend];
            }
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell;
        }
    }
    else
    {
        //先建立一个系统的tableviewcell
        static NSString *cscell=@"cscell";
        UITableViewCell *cellcs = [ tableView dequeueReusableCellWithIdentifier: cscell ];
        if (cellcs==nil) {
            cellcs = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cscell];
//            cellcs = [ [ UITableViewCell alloc ] initWithFrame: CGRectZero reuseIdentifier: cscell];
        }
        return cellcs;
    }
    
    
    
}





- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    
    
    if (indexPath.section==0) {
        
        if (indexPath.row==0) {
            //点击进入地图界面
            
            
//            UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"即将进入百度地图" message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:@"好", nil];
//            
//            [alert show];
            
            
           
            
            
            
            
            
//            UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
//            HLTshopmapViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"HLTshopmapViewController"];
//            vc.hidesBottomBarWhenPushed = YES;
//            
//            
////            NSString *shopid;
            NSString *shop_longitude;
            NSString *shop_latitude;
            NSString *Shop_name;
            NSString *Shop_address;
            
            
            
            if (_biaozhi) {
                shop_longitude=self.shopcontent.shop_longitude;
                shop_latitude=self.shopcontent.shop_latitude;
                Shop_name=self.shopcontent.Shop_name;
                Shop_address=self.shopcontent.Shop_address;
                
            }else
            {
//                shopid=self.zhoubianshopcontent.id;
                shop_longitude=self.zhoubianshopcontent.shop_longitude;
                shop_latitude=self.zhoubianshopcontent.shop_latitude;
                Shop_name=self.zhoubianshopcontent.name;
                Shop_address=self.zhoubianshopcontent.shop_address;
                
            }
            ////调用网页版的商家地图界面（&longitude=106.724542&latitude=26.576162&shopname=商户名&shopaddress=商铺地址）
            NSString *url=[NSString stringWithFormat:@"%@&longitude=%@&latitude=%@&shopname=%@&shopaddress=%@",shopmap,shop_longitude,shop_latitude,Shop_name,Shop_address];
            
            
            
            
            UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
            HLTuserchargeViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"HLTuserchargeViewController"];
            
            vc.hidesBottomBarWhenPushed = YES;
            vc.url=url;
            [vc setTitle:@"商家地图"];
            //这样就可以打开导航了
            self.yinchang=NO;
            
            //            HLTCustomerserviceTableViewController *vc =[[HLTCustomerserviceTableViewController alloc]init];
            [self.navigationController pushViewController:vc animated:NO];
            
            
//            [vc setmyWebview];
////                NSURL *lastURL=[NSURL URLWithString:url];
////                NSMutableURLRequest *newRequest = [NSMutableURLRequest requestWithURL:lastURL];
////                [vc.webview loadRequest:newRequest];
//            [self.navigationController pushViewController:vc animated:YES];
            
        }
        else if (indexPath.row==1)
        {//拨号
            
            NSString *tel;
            if (_biaozhi) {
                tel=self.shopcontent.Telephone;
            }else
            {
                tel=self.zhoubianshopcontent.telephone;
            }
            
            
            NSString *number = tel;// 此处读入电话号码
            
//            NSString *num = [[NSString alloc] initWithFormat:@"tel://%@",number]; //number为号码字符串 如果使用这个方法 结束电话之后会进入联系人列表
            
            
            
                NSString *num = [[NSString alloc] initWithFormat:@"telprompt://%@",number]; //而这个方法则打电话前先弹框  是否打电话 然后打完电话之后回到程序中 网上说这个方法可能不合法 无法通过审核
            
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:num]]; //拨号
            
            
            
        }
    }
    
    if (indexPath.section==2) {
        
        NSMutableArray * array=[NSMutableArray array];
        
//        NSArray * titiles1=@[@"全部",@"退款中",@"退款完成",@"拒绝退款",@"交易完成",@"待确认"];
        
        NSString *shopid;
        if (_biaozhi) {
            shopid=self.shopcontent.Shop_id;
        }else
        {
            shopid=self.zhoubianshopcontent.id;
        }
        
        
        NSArray * titiles=@[@"全部",@"好评",@"中评",@"差评"];
        for (int i=0; i<titiles.count; i++) {
            
            if (i==0) {
                HLTpinglunTableViewController *nex1= [[HLTpinglunTableViewController alloc] init];
                nex1.type=quanbu;
                nex1.shop_id=shopid;
                [array addObject:nex1];
            }
            else if (i==1)
            {
                HLTpinglunTableViewController *nex1= [[HLTpinglunTableViewController alloc] init];
                nex1.shop_id=shopid;
                nex1.type=haoping;
                
                
                [array addObject:nex1];
                
            }else if (i==2)
            {
                HLTpinglunTableViewController *nex1= [[HLTpinglunTableViewController alloc] init];
                nex1.shop_id=shopid;
                nex1.type=zhongping;
                [array addObject:nex1];
            }else if (i==3)
            {
                HLTpinglunTableViewController *nex1= [[HLTpinglunTableViewController alloc] init];
                nex1.shop_id=shopid;
                nex1.type=chaping;
                [array addObject:nex1];
            }
        }
        
        
        SliderViewController * next=[[SliderViewController alloc] initWithViewControllers:array];
        //            next.tag=1005;
        
        
        
        for (int i=0; i<[array count]; i++) {
            
            HLTpinglunTableViewController *vcc=array[i];
            vcc.parent=next;
            
        }
        
        
        next.titileArray=titiles;
        next.lineHeight=2;
        next.selectTextColor=navigationBarColor;
        
        next.selectBgColor=[UIColor whiteColor];
        next.defaultUnSelectBgColor=[UIColor lightGrayColor];
        // next.separateColor=[UIColor redColor];
        next.selectIndex=0;
        next.sliderDelegate=self;
        self.slider=next;
        self.yinchang=NO;
        //隐藏导航
        //这个是是否隐藏下面的tabbar
//        self.hidesBottomBarWhenPushed = NO;
//        next.navigationController.navigationBarHidden = NO;
//        self.navigationController.navigationBarHidden=NO;
        [self.navigationController pushViewController:next animated:YES];
       

        [self initNavigationBar:next];
    }
    
    if (indexPath.section==3) {
        
        if (indexPath.row!=0) {
            
            HLTZhoubianModel *recommend = _recommendArray[indexPath.row-1];
            //                    NSString *shopId = recommend.Shop_id;
            //            NSLog(@"shop id:%@",shopId);
            
            HLTShopViewController *shopvc=[[HLTShopViewController alloc]init];
//            shopvc.shopcontent=recommend;
            shopvc.zhoubianshopcontent=recommend;
            shopvc.biaozhi=NO;
            shopvc.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:shopvc animated:YES];
            
            
            
            
        }
        
    }
    
    
    
    }




#pragma mark slider的委托
-(void)sliderScrollerDidIndex:(NSInteger)index andSlider:(SliderViewController *)slider{
    
    NSString * tiitle=slider.titileArray[index];
    [slider.navigationItem setTitle:tiitle];
    //    slider.navigationController.title=tiitle;
}







//然后呢当然是自定义我们的navigation bar了
-(void)initNavigationBar:(SliderViewController *) slider
{
    //添加评论按钮
    
    UIButton *searchButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 50, 30)];
    [searchButton setTitle:@"评论" forState:UIControlStateNormal];
//    [searchButton setImage:[UIImage imageNamed:@"icon_search"] forState:UIControlStateNormal];
    [searchButton addTarget:self action:@selector(pinglun:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *searchItem = [[UIBarButtonItem alloc] initWithCustomView:searchButton];
    //     self.navigationItem.rightBarButtonItems = @[searchItem,moreItem];
    slider.navigationItem.rightBarButtonItem =searchItem;
    slider.navigationController.navigationBar.barTintColor = navigationBarColor;
}






//实现评论按钮点击事件
#pragma mark - handle button click
-(void) pinglun:(id)sender
{
    

    
    Account *acc=[[AccountTool sharedAccountTool] currentAccount];
   
            if(![acc.custIdent isEqual:@""])
            {
            
            UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
            
            HLTqupinglunTableViewController * search = [story instantiateViewControllerWithIdentifier:@"HLTqupinglunTableViewController"];
            
            search.shop_id=self.shopID;
                search.parent=self.slider;
                
            [self.slider.navigationController pushViewController:search animated:NO];
            }
        else
        {
            
            UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"评论失败" message:@"亲!还没有个人信息哟-_-" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"好", nil];
            [alert show];
            
        }
        
        
    
    
    
    
    
    
    
    
   
    
}


#pragma mark - 隐藏系统的导航条
- (void)viewDidAppear:(BOOL)animated
{
    //防止拖动一下就出现导航条的情况
    [super viewDidAppear:animated];
    
    if (!self.yinchang) {
        self.yinchang=YES;
        self.navigationController.navigationBarHidden = NO;
        
    }
    else
    {
        self.navigationController.navigationBarHidden = YES;
    }
}

- (void)viewDidDisappear:(BOOL)animated
{
    //防止拖动一下就出现导航条的情况
    [super viewDidDisappear:animated];
//    self.navigationController.navigationBarHidden = YES;
    if (!self.yinchang) {
        self.yinchang=YES;
        self.navigationController.navigationBarHidden = NO;
    }
    else{
        self.navigationController.navigationBarHidden = YES;
    }
    
    
    
    
}





- (void)viewWillDisappear:(BOOL)animated
{
    
    self.hidesBottomBarWhenPushed=YES;
    [super viewWillDisappear:animated];
//    self.navigationController.navigationBarHidden = YES;
    
    if (!self.yinchang) {
        self.navigationController.navigationBarHidden = NO;
    }
    else{
         self.navigationController.navigationBarHidden = YES;
    }
    
//    self.yinchang=YES;
}

//-(RecommendModel *) getrecommendmodel:*(HLTZhoubianModel *) zhoubianmodel
//{
////    RecommendModel *recommend
//    
//}

//给rmdTableView添加title时用到的cell,注意identifier这个变量是要传一个static的
-(UITableViewCell *) gettitlecell:(NSString *)identifier title:(NSString *) title
{
     NSString *cellIndentifier = identifier;
    UITableViewCell *cell = [self.rmdTableView dequeueReusableCellWithIdentifier:cellIndentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIndentifier];
    }
    cell.backgroundColor=navigationBarColor;
    cell.textLabel.text = title;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
    
}




@end
